{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "from download_data import multi_p_run, put_worker, _worker, download_mp4, download_align"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## TEST"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34]\n",
      "5\n",
      "35 >> [[0, 7], [7, 14], [14, 21], [21, 28], [28, 35]]\n",
      "[{'succ': {0, 1, 2, 3, 4, 5, 6}, 'fail': set()}, {'succ': {7, 8, 9, 10, 11, 12, 13}, 'fail': set()}, {'succ': {14, 15, 16, 17, 18, 19, 20}, 'fail': set()}, {'succ': {21, 22, 23, 24, 25, 26, 27}, 'fail': set()}, {'succ': {32, 33, 34, 28, 29, 30, 31}, 'fail': set()}]\n"
     ]
    }
   ],
   "source": [
    "res = multi_p_run(35, put_worker, _worker, 5)\n",
    "print (res)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Download Data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "## down\n",
    "import os\n",
    "os.makedirs('./datasets', exist_ok=True)\n",
    "#os.system('rm -rf ./datasets/*')\n",
    "\n",
    "res = multi_p_run(35, put_worker, download_align, 9)\n",
    "print (res)\n",
    "\n",
    "os.system('rm -f datasets/*.tar && rm -f datasets/align/Thumbs.db')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "res = multi_p_run(35, put_worker, download_mp4, 9)\n",
    "print (res)\n",
    "\n",
    "os.system('rm -f datasets/*.zip && rm -f datasets/*/Thumbs.db')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "## download single 22 th dir\n",
    "#download_data.py(22, 22)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Preprocess Data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "from preprocess_data import preprocess, find_files, Video"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import os\n",
    "os.makedirs('./TARGET', exist_ok=True)\n",
    "os.system('rm -rf ./TARGET/*')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34]\n",
      "9\n",
      "35 >> [[0, 4], [4, 8], [8, 12], [12, 16], [16, 20], [20, 24], [24, 28], [28, 32], [32, 35]]\n",
      "Processing: datasets/s1/prwq3s.mpg\n",
      "Processing: datasets/s4/lrix7n.mpg\n",
      "Processing: datasets/s8/pgbyza.mpg\n",
      "Processing: datasets/s12/brik7n.mpg\n",
      "Processing: datasets/s16/sgit7p.mpg\n",
      "Processing: datasets/s20/lrbp8a.mpg\n",
      "Processing: datasets/s24/sbik8a.mpg\n",
      "Processing: datasets/s28/srwf8a.mpg\n",
      "Processing: datasets/s32/pbbm1n.mpg\n",
      "Processing: datasets/s12/sbbaza.mpg\n",
      "Processing: datasets/s28/lbit7n.mpg\n",
      "Processing: datasets/s32/pbwm7p.mpg\n",
      "Processing: datasets/s8/bril2s.mpg\n",
      "Processing: datasets/s20/bway7n.mpg\n",
      "Processing: datasets/s1/pbib8p.mpg\n",
      "Processing: datasets/s16/lwaj7n.mpg\n",
      "Processing: datasets/s24/bwwl6a.mpg\n",
      "Processing: datasets/s4/bbwf7n.mpg\n"
     ]
    }
   ],
   "source": [
    "res = multi_p_run(35, put_worker, preprocess, 9)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
